package com.chouxiaozi.promotion;

public enum StrategyTypeEnum {

    CASH_BACK("cash_back",CashbackStrategy.class),
    GROUP_BUY("group_buy",GroupbuyStrategy.class),
    TICKET("ticket",TicketStrategy.class);

    private String type;
    private Class<IPromotionStrategy> clazz;

    private StrategyTypeEnum(String type, Class clazz){
        this.type = type;
        this.clazz = clazz;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Class<IPromotionStrategy> getClazz() {
        return clazz;
    }

    public void setClazz(Class<IPromotionStrategy> clazz) {
        this.clazz = clazz;
    }

    public static StrategyTypeEnum getStrategyByType(String type){
        for (StrategyTypeEnum value : StrategyTypeEnum.values()) {
            if(value.getType().equals(type)){
                return value;
            }
        }
        return null;
    }
}
